<template>
    <div>
        <el-form :model="formData" label-width="160px">
            <el-form-item label="状态:" prop="sort">
                <el-radio-group v-model="formData.status" class="ml-4">
                    <el-radio-button :label="0">关闭</el-radio-button>
                    <el-radio-button :label="1">开启</el-radio-button>
                </el-radio-group>
            </el-form-item>
            <el-form-item>
                <span style="color:red;cursor:pointer;">温馨提示：开启后SaaS用户可扫码授权发布微信小程序</span>
            </el-form-item>
            <el-form-item label="开发小程序appid:">
                <div class="w-80">
                    <el-input class="w-[280px]" v-model="formData.appid" placeholder="请输入开发小程序appid" />
                </div>
            </el-form-item>
            <el-form-item>
                <span style="color:red;cursor:pointer;">小程序需要绑定微信开放平台
                    <span @click="tokf">-【去绑定】</span>
                    <span @click="dialogVisible = true">-【查看示例】</span>
                </span>
            </el-form-item>
        </el-form>
        <footer-btns>
            <el-button type="primary" @click="setData">保存</el-button>
        </footer-btns>
        <el-dialog
            v-model="dialogVisible"
            width="80%"
        >
            <img  src="../../../assets/images/wxkf.png"  alt="" style="width:100%;" @click="dialogVisible = false"/>
        </el-dialog>
    </div>
</template>

<script lang="ts" setup>
import { getconfig,setconfig } from "@/api/application/chanel";
import { usePaging } from "@/hooks/usenew";
import feedback from "@/utils/feedback";
const route = useRoute()
const dialogVisible = ref(false)
const formData = ref({
    status:0,
    appid:"",
    app:route.query.app
})
const getData = async() => {
    const data = await getconfig({app:route.query.app})
    formData.value = data
    formData.value.app = route.query.app
}
getData()
const setData = async() => {
    await setconfig(formData.value)
}
const tokf = () => {
    window.open("https://open.weixin.qq.com/")
}
</script>